package net.chenlin.dp.base.service.impl;

import net.chenlin.dp.base.entity.CompanyEntity;
import net.chenlin.dp.base.manager.CompanyManager;
import net.chenlin.dp.base.service.CompanyService;
import net.chenlin.dp.common.entity.Page;
import net.chenlin.dp.common.entity.Query;
import net.chenlin.dp.common.entity.R;
import net.chenlin.dp.common.utils.CommonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 公司管理
 *
 * @author ZhouChenglin
 * @email yczclcn@163.com
 * @url www.chenlintech.com
 * @date 2018年2月02日 下午4:38:09
 */
@Service("companyService")
public class CompanyServiceImpl implements CompanyService {

	@Autowired
	private CompanyManager companyManger;

	@Override
	public Page<CompanyEntity> listDpCompany(Map<String, Object> params) {
		Query query = new Query(params);
		Page<CompanyEntity> page = new Page<>(query);
		companyManger.listDpCompany(page, query);
		return page;
	}

	@Override
	public R saveDpCompany(CompanyEntity role) {
		int count = companyManger.saveDpCompany(role);
		return CommonUtils.msg(count);
	}

	@Override
	public R getDpCompanyById(Long id) {
		CompanyEntity dpCompany = companyManger.getDpCompanyById(id);
		return CommonUtils.msg(dpCompany);
	}

	@Override
	public R updateDpCompany(CompanyEntity dpCompany) {
		int count = companyManger.updateDpCompany(dpCompany);
		return CommonUtils.msg(count);
	}

	@Override
	public R batchRemove(Long[] id) {
		int count = companyManger.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
